package edu.berkeley.cs160.innovationers.shoppersidekick;



import java.util.Hashtable;


import android.content.Context;
import android.graphics.Bitmap;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;

public class MemberAdapterView extends LinearLayout {

	private static Hashtable<String, Bitmap> Pics = new Hashtable<String, Bitmap>();
	
	public MemberAdapterView(Context context, Member mem) {
		super(context);
		setPadding(0, 5, 0, 0);
		LinearLayout.LayoutParams params = 
            new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		
		String myName = mem.getName();
		TextView MemberName = new TextView(context);
		MemberName.setText(myName);
		
		ImageView img = new ImageView(context);
		Bitmap user_pic = null;
		if((user_pic = Pics.get(myName)) == null){
			//get picture via facebook
			//Pics.put(myName, user_pic);
			img.setImageBitmap(user_pic);
		}else{
			img.setImageBitmap(user_pic);
		}
		img.setImageResource(R.drawable.default_large);
		addView(img, params);
		params.setMargins(5, 0, 0, 0);
		addView(MemberName, params);
	}
}